/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.*;

/**
 * <p>Project: app2022 - FileReader1
 * <p>Powered by webrx On 2022-01-19 11:47:59
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class FileReader1 {
    public static void main(String[] args) {
        //写入文件,并读取文件。
        String f = "myc.txt";
        try (var fw = new FileWriter(f, true); var fr = new BufferedReader(new FileReader(f))) {
            fw.write("hello中文\njava编程\n");
            fw.write(String.format("%tF %<tT %n", System.currentTimeMillis()));
            fw.flush();
            System.out.println("写入文件，完成。");
            while (fr.ready()) {
                System.out.println(fr.readLine());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
